package com.aletto.general_store.presenters;

import android.content.Context;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.aletto.general_store.R;
import com.aletto.general_store.data.model.Goods;
import com.aletto.general_store.ui.GoodsGridItemDecoration;
import com.aletto.general_store.ui.activities.GoodsDetailsActivity;
import com.aletto.general_store.ui.adapters.GoodsListAdapter;
import com.aletto.general_store.ui.adapters.SearchGoodsLinerAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;

import me.jessyan.autosize.utils.AutoSizeUtils;

public class SearchGoodsLinearPageTemplate extends SearchGoodsPageTemplate {

    public SearchGoodsLinearPageTemplate(RecyclerView recyclerView, SmartRefreshLayout refreshLayout) {
        super(recyclerView, refreshLayout);
        Context context = recyclerView.getContext();
        recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    }

    @Override
    public BaseQuickAdapter<Goods, BaseViewHolder> adapter(RecyclerView recyclerView) {
        SearchGoodsLinerAdapter goodsListAdapter = new SearchGoodsLinerAdapter();

        // 商品详情
        goodsListAdapter.setOnItemClickListener((adapter, view, position) -> {
            Context context = view.getContext();
            Goods goods = (Goods) adapter.getItem(position);
            context.startActivity(GoodsDetailsActivity.newIntent(context, goods));
        });

        return goodsListAdapter;
    }

}
